﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using C4F.DevKit.WebServices;
using C4F.DevKit.WebServices.Datasets;
using System.IO;


namespace C4F.DevKit.WebServicesDemo
{
    public partial class YahooTrafficControl : UserControl
    {
        public YahooTrafficControl()
        {
            InitializeComponent();
        }

        private void GoButton_Click(object sender, EventArgs e)
        {
            try
            {
                YahooTrafficService.ApplicationKey = ApplicationKey.Text;
                YahooTrafficResults = YahooTrafficService.GetTraffic_DS(SearchLocation.Text);
                YahooTrafficGrid.DataSource = YahooTrafficResults.TrafficIncident;
            }
            catch (System.Net.WebException ex)
            {
                StreamReader streamReader = new StreamReader(ex.Response.GetResponseStream());
                string responseData = streamReader.ReadToEnd();
                streamReader.Close();
                MessageBox.Show(responseData);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

    }
}
